class AuthenticationManager
{
public:
    AuthenticationManager(int timeToLive)
    {
        this->timeToLive = timeToLive;
    }

    void generate(string tokenId, int currentTime)
    {
        tokens[tokenId] = currentTime;
    }

    void renew(string tokenId, int currentTime)
    {
        if (tokens.count(tokenId))
        {
            int generateTime = tokens[tokenId];
            if (currentTime - generateTime >= timeToLive)
            {
                tokens.erase(tokenId);
                return;
            }
            tokens[tokenId] = currentTime;
        }
    }

    int countUnexpiredTokens(int currentTime)
    {
        vector<string> expired;
        for (auto &[token, generateTime] : tokens)
        {
            if (currentTime - generateTime >= timeToLive)
            {
                expired.push_back(token);
            }
        }
        for (auto &token : expired)
        {
            tokens.erase(token);
        }
        return tokens.size();
    }

private:
    int timeToLive;
    unordered_map<string, int> tokens;
};

/**
 * Your AuthenticationManager object will be instantiated and called as such:
 * AuthenticationManager* obj = new AuthenticationManager(timeToLive);
 * obj->generate(tokenId,currentTime);
 * obj->renew(tokenId,currentTime);
 * int param_3 = obj->countUnexpiredTokens(currentTime);
 */